//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cc.rengu.redp.bizimpl.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

public class ExtPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
    private static Logger logger = LoggerFactory.getLogger(ExtPropertyPlaceholderConfigurer.class);
    private static Map<String, String> ctxPropertiesMap;

    public ExtPropertyPlaceholderConfigurer() {
    }

    protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
        super.processProperties(beanFactoryToProcess, props);
        ctxPropertiesMap = new HashMap();
        logger.info("Putting PropertyPlaceholder {}  datas into cache...", props.size());
        Iterator i$ = props.keySet().iterator();

        while(i$.hasNext()) {
            Object key = i$.next();
            String keyStr = key.toString();
            String value = props.getProperty(keyStr);
            ctxPropertiesMap.put(keyStr, value);
            if (keyStr.startsWith("env.")) {
                System.setProperty(keyStr, value);
            }
        }

    }

    public String getProperty(String name) {
        return (String)ctxPropertiesMap.get(name);
    }
}
